package com.acp.service.impl;

import com.acp.context.Config;
import com.acp.dao.acp.*;
import com.acp.dao.acpo.*;
import com.acp.dao.acpo.monomer.*;
import com.acp.model.*;
import com.acp.model.monomer.*;
import com.acp.result.PageResult;
import com.acp.result.ResultInfo;
import com.acp.result.ResultUtil;
import com.acp.service.ObjectInfoService;
import com.acp.service.monomer.HistoricalBuildingIndividualService;
import com.acp.util.UUIDBuild;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.tomcat.jni.FileInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.controller.construction
 * @Description: 采集管理实现类
 * @author: 张星亮
 * @date: 2019/4/5
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ObjectInfoServiceImpl implements ObjectInfoService {
    @Resource
    private HistoricalAreaMapper historicalAreaMapper;//历史地段
    @Resource
    private HistoricalBuildingMapper historicalBuildingMapper;//历史建筑
    @Resource
    private HistoricalStreetMapper historicalStreetMapper;//历史文化街区
    @Resource
    private HsataocMapper hsataocMapper;//近现代重要史迹及代表性建筑
    @Resource
    private IndustrialHeritageMapper industrialHeritageMapper;//工业遗产
    @Resource
    private LayoutStyleMapper layoutStyleMapper;//整体格局与风貌
    @Resource
    private NchMapper nchMapper;//非物质文化遗产
    @Resource
    private OldStructureMapper oldStructureMapper;//古构筑物
    @Resource
    private OldTreeMapper oldTreeMapper;//古树名木
    @Resource
    private OldWallMapper oldWallMapper;//古城墙
    @Resource
    private OthersMapper othersMapper;//X
    @Resource
    private ProtectionUnitMapper protectionUnitMapper;//文控保单位
    @Resource
    private SuzhouGardensMapper suzhouGardensMapper;//苏州园林
    @Resource
    private TraditionalHousesMapper traditionalHousesMapper;//传统民居
    @Resource
    private TraditionalIndustryMapper traditionalIndustryMapper;//传统产业
    @Resource
    private UcrMapper ucrMapper;//尚未核定为文物保护单位的不可移动文物
    @Resource
    private WatercourseMapper watercourseMapper;//河道水系
    @Resource
    private WuCulturePlaceMapper wuCulturePlaceMapper;//吴文化地名
    @Resource
    private DictMapper dictMapper;//字典表
    @Resource
    private RetrievalMapper retrievalMapper;//对象大表
    @Resource
    private UarMapper uarMapper;//地下文物埋藏区
    @Resource
    private StreetCommunityMapper streetCommunityMapper;//街道社区
    @Resource
    private DcsInputCodeMapper dcsInputCodeMapper;
    @Resource
    private DcsPerformanceMapper dcsPerformanceMapper;
    @Resource
    private DcsTaskPerformanceMapper dcsTaskPerformanceMapper;

    @Resource
    private DcsSelectAllTempMapper dcsSelectAllTempMapper;

    @Resource
    private DcsCollectCodeMapper dcsCollectCodeMapper;

    @Resource
    private DcsCheckMapper dcsCheckMapper;

    @Resource
    private AcpHistoricalAreaMapper acpHistoricalAreaMapper;

    @Resource
    private AcpHistoricalBuildingMapper acpHistoricalBuildingMapper;

    @Resource
    private AcpHistoricalStreetMapper acpHistoricalStreetMapper;

    @Resource
    private AcpHsataocMapper acpHsataocMapper;

    @Resource
    private AcpIndustrialHeritageMapper acpIndustrialHeritageMapper;

    @Resource
    private AcpNchMapper acpNchMapper;

    @Resource
    private AcpOldStructureMapper acpOldStructureMapper;

    @Resource
    private AcpOldTreeMapper acpOldTreeMapper;

    @Resource
    private AcpOldWallMapper acpOldWallMapper;

    @Resource
    private AcpProtectionUnitMapper acpProtectionUnitMapper;

    @Resource
    private AcpSuzhouGardensMapper acpSuzhouGardensMapper;

    @Resource
    private AcpTraditionalHousesMapper acpTraditionalHousesMapper;

    @Resource
    private AcpTraditionalIndustryMapper acpTraditionalIndustryMapper;

    @Resource
    private AcpUarMapper acpUarMapper;

    @Resource
    private AcpUcrMapper acpUcrMapper;

    @Resource
    private AcpWatercourseMapper acpWatercourseMapper;

    @Resource
    private AcpWuCulturePlaceMapper acpWuCulturePlaceMapper;

    @Resource
    private HistoricalBuildingIndividualMapper historicalBuildingIndividualMapper;

    @Resource
    private ProtectionUnitIndividualMapper protectionUnitIndividualMapper;

    @Resource
    private HsataocIndividualMapper hsataocIndividualMapper;

    @Resource
    private IndustrialHeritageIndividualMapper industrialHeritageIndividualMapper;

    @Resource
    private SuzhouGardensIndividualMapper suzhouGardensIndividualMapper;

    @Resource
    private TraditionalHousesIndividualMapper traditionalHousesIndividualMapper;

    @Resource
    private UcrIndividualMapper ucrIndividualMapper;

    @Resource
    private AcpHistoricalBuildingIndividualMapper acpHistoricalBuildingIndividualMapper;

    @Resource
    private AcpHsataocIndividualMapper acpHsataocIndividualMapper;

    @Resource
    private AcpIndustrialHeritageIndividualMapper acpIndustrialHeritageIndividualMapper;

    @Resource
    private AcpProtectionUnitIndividualMapper acpProtectionUnitIndividualMapper;

    @Resource
    private AcpSuzhouGardensIndividualMapper acpSuzhouGardensIndividualMapper;

    @Resource
    private AcpTraditionalHousesIndividualMapper acpTraditionalHousesIndividualMapper;

    @Resource
    private AcpUcrIndividualMapper acpUcrIndividualMapper;


    @Value("${upload.url}")
    private String url;

    @Value("C://uploadFiles/photo/")
    private String urlIp;
    /**
     * 查询
     * @param type
     * @param pageNum
     * @param pageSize
     * @return 返回PageResult 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public PageResult getObjectNameLst(String type, Integer pageNum, Integer pageSize) {
        // 分页插件
        PageHelper.startPage(pageNum, pageSize);
        long count;
        List<Object> list = new ArrayList<>();
        List<Retrieval> retrievalLst = new ArrayList<>();
        String tableName;
        switch (type){
            case "吴文化地名":
            tableName = "wu_culture_place";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                WuCulturePlace wuCulturePlace = wuCulturePlaceMapper.selectByPrimaryKey(retrieval.getId());
                if (wuCulturePlace != null) {
                    wuCulturePlace.setStatus(retrieval.getStatus());
                    wuCulturePlace.setType("吴文化地名");
                    wuCulturePlace.setTableName(tableName);
                    list.add(wuCulturePlace);
                }
            }
            break;
            case "传统产业":
            tableName = "traditional_industry";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                TraditionalIndustry traditionalIndustry = traditionalIndustryMapper.selectByPrimaryKey(retrieval.getId());
                if (traditionalIndustry != null) {
                    traditionalIndustry.setStatus(retrieval.getStatus());
                    list.add(traditionalIndustry);
                }
            }
            break;
            case "历史文化街区":
            tableName = "historical_street";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                HistoricalStreet historicalStreet = historicalStreetMapper.selectByPrimaryKey(retrieval.getId());
                if (historicalStreet != null) {
                    historicalStreet.setStatus(retrieval.getStatus());
                    list.add(historicalStreet);
                }
            }
            break;
            case "历史地段":
            tableName = "historical_area";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                HistoricalArea historicalArea = historicalAreaMapper.selectByPrimaryKey(retrieval.getId());
                if (historicalArea != null) {
                    historicalArea.setStatus(retrieval.getStatus());
                    list.add(historicalArea);
                }
            }
            break;
            case "河道水系":
            tableName = "watercourse";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                Watercourse watercourse = watercourseMapper.selectByPrimaryKey(retrieval.getId());
                if (watercourse != null) {
                    watercourse.setStatus(retrieval.getStatus());
                    list.add(watercourse);
                }
            }
            break;
            case "文控保单位":
            tableName = "protection_unit";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                ProtectionUnit protectionUnit = protectionUnitMapper.selectByPrimaryKey(retrieval.getId());
                if (protectionUnit != null) {
                    String dynasty = protectionUnit.getDynasty();
                    protectionUnit.setDynasty(dynasty);
                    protectionUnit.setStatus(retrieval.getStatus());
                    list.add(protectionUnit);
                }
            }
            break;
            case "尚未核定为文物保护单位的不可移动文物":
            tableName = "ucr";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                Ucr ucr = ucrMapper.selectByPrimaryKey(retrieval.getId());
                if (ucr != null) {
                    String dynasty = ucr.getDynasty();
                    ucr.setDynasty(dynasty);
                    ucr.setStatus(retrieval.getStatus());
                    list.add(ucr);
                }
            }
            break;
            case "历史建筑":
            tableName = "historical_building";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                HistoricalBuilding historicalBuilding = historicalBuildingMapper.selectByPrimaryKey(retrieval.getId());
                if (historicalBuilding != null) {
                    historicalBuilding.setStatus(retrieval.getStatus());
                    list.add(historicalBuilding);
                }
            }
            break;
            case "苏州园林":
            tableName = "suzhou_gardens";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                SuzhouGardens suzhouGardens = suzhouGardensMapper.selectByPrimaryKey(retrieval.getId());
                if (suzhouGardens != null) {
                    String dateFrom = suzhouGardens.getDynasty();
                    String dateTo = suzhouGardens.getDynastycode();
                    String dynasty = dateFrom;
                    suzhouGardens.setDynasty(dynasty);
                    suzhouGardens.setStatus(retrieval.getStatus());
                    list.add(suzhouGardens);
                }
            }
            break;
            case "近现代重要史迹及代表性建筑":
            tableName = "hsataoc";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                Hsataoc hsataoc = hsataocMapper.selectByPrimaryKey(retrieval.getId());
                if (hsataoc != null) {
                    hsataoc.setStatus(retrieval.getStatus());
                    list.add(hsataoc);
                }
            }
            break;
            case "古城墙":
            tableName = "old_wall";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                OldWall oldWall = oldWallMapper.selectByPrimaryKey(retrieval.getId());
                if (oldWall != null) {
                    String dynasty = oldWall.getDynasty();
                    oldWall.setDynasty(dynasty);
                    oldWall.setStatus(retrieval.getStatus());
                    list.add(oldWall);
                }
            }
            break;
            case "传统民居":
            tableName = "traditional_houses";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                TraditionalHouses TraditionalHouses = traditionalHousesMapper.selectByPrimaryKey(retrieval.getId());
                if (TraditionalHouses != null) {
                    String dynasty = TraditionalHouses.getDynasty();
                    TraditionalHouses.setDynasty(dynasty);
                    TraditionalHouses.setStatus(retrieval.getStatus());
                    if ("1".equals(TraditionalHouses.getProtectionGrade())) {
                        TraditionalHouses.setGrade("优秀传统民居");
                    } else if ("".equals(TraditionalHouses.getProtectionGrade())) {
                        TraditionalHouses.setGrade("一般传统民居");
                    }
                    list.add(TraditionalHouses);
                }
            }
            break;
            case "古树名木":
            tableName = "old_tree";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                OldTree oldTree = oldTreeMapper.selectByPrimaryKey(retrieval.getId());
                if (oldTree != null) {
                    oldTree.setStatus(retrieval.getStatus());
                    list.add(oldTree);
                }
            }
            case "工业遗产":
            tableName = "industrial_heritage";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                IndustrialHeritage industrialHeritage = industrialHeritageMapper.selectByPrimaryKey(retrieval.getId());
                if (industrialHeritage != null) {
                    industrialHeritage.setStatus(retrieval.getStatus());
                    list.add(industrialHeritage);
                }
            }
            break;
            case "古构筑物":
            tableName = "old_structure";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                OldStructure oldStructure = oldStructureMapper.selectByPrimaryKey(retrieval.getId());
                if (oldStructure != null) {
                    String dynasty = oldStructure.getDynasty();
                    oldStructure.setDynasty(dynasty);
                    oldStructure.setStatus(retrieval.getStatus());
                    list.add(oldStructure);
                }
            }
            break;
            case "非物质文化遗产":
            tableName = "nch";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                Nch nch = nchMapper.selectByPrimaryKey(retrieval.getId());
                if (nch != null) {
                    nch.setStatus(retrieval.getStatus());
                    list.add(nch);
                }
            }
            break;
            case "整体格局与风貌":
            tableName = "layout_style";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                LayoutStyle layoutStyle = layoutStyleMapper.selectByPrimaryKey(retrieval.getId());
                if (layoutStyle != null) {
                    layoutStyle.setStatus(retrieval.getStatus());
                    list.add(layoutStyle);
                }
            }
            break;
            case "地下文物埋藏区":
            tableName = "uar";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                Uar uar = uarMapper.selectByPrimaryKey(retrieval.getId());
                if (uar != null) {
                    uar.setStatus(retrieval.getStatus());
                    list.add(uar);
                }
            }
            break;
            case "X":
            tableName = "others";
            retrievalLst = retrievalMapper.selectByTableName(tableName);
            for (Retrieval retrieval : retrievalLst) {
                Others others = othersMapper.selectByPrimaryKey(retrieval.getId());
                if (others != null) {
                    others.setStatus(retrieval.getStatus());
                    list.add(others);
                }
            }
            break;
            default:
                break;
    }
        PageInfo<?> pageInfo = new PageInfo<>(retrievalLst);
        count = pageInfo.getTotal();

        return PageResult.success(list, count);
    }

    /**
     * 查询列表
     * @param object
     * @return 返回PageResult 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public PageResult findList(String object) {
        String searchMap = doValue(object, "searchMap");
        String type = doValue(object, "type");
        String name = doValue(object, "name");
        String status = doValue(object, "status");
        String street = doValue(object, "street");
        String level = doValue(object, "level");
        String community = doValue(object, "community");
        // 分页插件
        long count;
        List<Object> list;
        list = queryList(type, name, status, street, level, community);
        PageInfo<?> pageInfo = new PageInfo<>(list);
        count = pageInfo.getTotal();
        return PageResult.success(list, count);
    }

    /**
     * 新增
     * @param id
     * @param name
     * @param tableName
     * @return int 类型数字
     */
    private int insertRetrieval(String id, String name, String tableName) {
        Retrieval retrieval = retrievalMapper.selectByName(new Retrieval(name, tableName));
        int ret;
        if (retrieval == null) {
            String sql = "insert into object_manager(id,name,table_name,status) values ('" + id + "','" + name + "','" + tableName + "','待审核')";
            ret = retrievalMapper.insertObjectBatch(sql);
        } else {
            ret = 0;
        }

        return ret;
    }

    /**
     * 添加采集数据
     * @param object
     * @return 返回ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public ResultInfo addObjectInfo(String object) {
        String type = doValue(object, "type");
        String pojo = doValue(object, "pojo");
        String name = doValue(pojo, "name");
        int ret = 0;
        int result = 0;
        JSONObject jsonObject = JSONObject.parseObject(pojo);
        String tableName;
        String id = UUIDBuild.getUUID();
        switch (type){
            case "吴文化地名":
            WuCulturePlace wuCulturePlace = JSONObject.toJavaObject(jsonObject, WuCulturePlace.class);
            tableName = "wu_culture_place";
            wuCulturePlace.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = wuCulturePlaceMapper.insert(wuCulturePlace);
            break;
            case "传统产业":
            TraditionalIndustry traditionalIndustry = JSONObject.toJavaObject(jsonObject, TraditionalIndustry.class);
            tableName = "traditional_industry";
            traditionalIndustry.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = traditionalIndustryMapper.insert(traditionalIndustry);
            break;
            case "历史文化街区":
            HistoricalStreet historicalStreet = JSONObject.toJavaObject(jsonObject, HistoricalStreet.class);
            tableName = "historical_street";
            historicalStreet.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = historicalStreetMapper.insert(historicalStreet);
            break;
            case "历史地段":
            HistoricalArea historicalArea = JSONObject.toJavaObject(jsonObject, HistoricalArea.class);
            tableName = "historical_area";
            historicalArea.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = historicalAreaMapper.insert(historicalArea);
            break;
            case "河道水系":
            Watercourse watercourse = JSONObject.toJavaObject(jsonObject, Watercourse.class);
            tableName = "watercourse";
            watercourse.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = watercourseMapper.insert(watercourse);
            break;
            case "文控保单位":
            ProtectionUnitWithBLOBs protectionUnit = JSONObject.toJavaObject(jsonObject, ProtectionUnitWithBLOBs.class);
            tableName = "protection_unit";
            protectionUnit.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = protectionUnitMapper.insert(protectionUnit);
            break;
            case "尚未核定为文物保护单位的不可移动文物":
            Ucr ucr = JSONObject.toJavaObject(jsonObject, Ucr.class);
            tableName = "ucr";
            ucr.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = ucrMapper.insert(ucr);
            break;
            case "历史建筑":
            HistoricalBuilding historicalBuilding = JSONObject.toJavaObject(jsonObject, HistoricalBuilding.class);
            tableName = "historical_building";
            historicalBuilding.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = historicalBuildingMapper.insert(historicalBuilding);
            break;
            case "苏州园林":
            SuzhouGardens suzhouGardens = JSONObject.toJavaObject(jsonObject, SuzhouGardens.class);
            tableName = "suzhou_gardens";
            suzhouGardens.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = suzhouGardensMapper.insert(suzhouGardens);
            break;
            case "近现代重要史迹及代表性建筑":
            Hsataoc hsataoc = JSONObject.toJavaObject(jsonObject, Hsataoc.class);
            tableName = "hsataoc";
            hsataoc.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = hsataocMapper.insert(hsataoc);
            break;
            case "古城墙":
            OldWallWithBLOBs oldWallWithBLOBs = JSONObject.toJavaObject(jsonObject, OldWallWithBLOBs.class);
            tableName = "old_wall";
            oldWallWithBLOBs.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = oldWallMapper.insert(oldWallWithBLOBs);
            break;
            case "传统民居":
            TraditionalHouses TraditionalHouses = JSONObject.toJavaObject(jsonObject, com.acp.model.TraditionalHouses.class);
            tableName = "traditional_houses";
            TraditionalHouses.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = traditionalHousesMapper.insert(TraditionalHouses);
            break;
            case "古树名木":
            OldTree oldTree = JSONObject.toJavaObject(jsonObject, OldTree.class);
            tableName = "old_tree";
            oldTree.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = oldTreeMapper.insert(oldTree);
            break;
            case "工业遗产":
            IndustrialHeritage industrialHeritage = JSONObject.toJavaObject(jsonObject, IndustrialHeritage.class);
            tableName = "industrial_heritage";
            industrialHeritage.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = industrialHeritageMapper.insert(industrialHeritage);
            break;
            case "古构筑物":
            OldStructure oldStructure = JSONObject.toJavaObject(jsonObject, OldStructure.class);
            tableName = "old_structure";
            oldStructure.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = oldStructureMapper.insert(oldStructure);
            break;
            case "非物质文化遗产":
            Nch nch = JSONObject.toJavaObject(jsonObject, Nch.class);
            tableName = "nch";
            nch.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = nchMapper.insert(nch);
            break;
            case "整体格局与风貌":
            LayoutStyle layoutStyle = JSONObject.toJavaObject(jsonObject, LayoutStyle.class);
            tableName = "layout_style";
            layoutStyle.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = layoutStyleMapper.insert(layoutStyle);
            break;
            case "地下文物埋藏区":
            Uar uar = JSONObject.toJavaObject(jsonObject, Uar.class);
            tableName = "uar";
            uar.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = uarMapper.insert(uar);
            break;
            case "X":
            Others others = JSONObject.toJavaObject(jsonObject, Others.class);
            tableName = "others";
            others.setId(id);
            result = insertRetrieval(id, name, tableName);
            if (result <= 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 303, null);
            }
            ret = othersMapper.insert(others);
            break;
            default:
                break;
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
    }

    /**
     * 修改数据
     * @param object
     * @return 返回ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public ResultInfo updateObjectInfo(String object) {
        Map maps = (Map) JSON.parse(object);
        JSONObject jsonObject = JSONObject.parseObject(maps.get("pojo").toString());
        String type = maps.get("type").toString();
        Date date = new Date();
        DcsInputCode dcsInputCode = null;
        int ret;
        switch (type){
            case "吴文化地名":
            WuCulturePlace wuCulturePlace = JSONObject.toJavaObject(jsonObject, WuCulturePlace.class);
            ret = wuCulturePlaceMapper.updateByPrimaryKey(wuCulturePlace);
            dcsInputCode = DcsInputCode.builder().id(wuCulturePlace.getId()).updateTime(date).build();
            dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "传统产业":
            TraditionalIndustry traditionalIndustry = JSONObject.toJavaObject(jsonObject, TraditionalIndustry.class);
            ret = traditionalIndustryMapper.updateByPrimaryKey(traditionalIndustry);
            dcsInputCode = DcsInputCode.builder().id(traditionalIndustry.getId()).updateTime(date).build();
            dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;

             case "历史文化街区":
            HistoricalStreet historicalStreet = JSONObject.toJavaObject(jsonObject, HistoricalStreet.class);
            ret = historicalStreetMapper.updateByPrimaryKey(historicalStreet);
             dcsInputCode = DcsInputCode.builder().id(historicalStreet.getId()).updateTime(date).build();
             dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "历史地段":
            HistoricalArea historicalArea = JSONObject.toJavaObject(jsonObject, HistoricalArea.class);
            ret = historicalAreaMapper.updateByPrimaryKey(historicalArea);
                dcsInputCode = DcsInputCode.builder().id(historicalArea.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "河道水系":
            Watercourse watercourse = JSONObject.toJavaObject(jsonObject, Watercourse.class);
            ret = watercourseMapper.updateByPrimaryKey(watercourse);
                dcsInputCode = DcsInputCode.builder().id(watercourse.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "文控保单位":
            ProtectionUnit protectionUnit = JSONObject.toJavaObject(jsonObject, ProtectionUnit.class);
            ret = protectionUnitMapper.updateByPrimaryKey(protectionUnit);
                dcsInputCode = DcsInputCode.builder().id(protectionUnit.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "尚未核定为文物保护单位的不可移动文物":
            Ucr ucr = JSONObject.toJavaObject(jsonObject, Ucr.class);
            ret = ucrMapper.updateByPrimaryKey(ucr);
                dcsInputCode = DcsInputCode.builder().id(ucr.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "历史建筑":
            HistoricalBuilding historicalBuilding = JSONObject.toJavaObject(jsonObject, HistoricalBuilding.class);
            ret = historicalBuildingMapper.updateByPrimaryKey(historicalBuilding);
                dcsInputCode = DcsInputCode.builder().id(historicalBuilding.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
             case "苏州园林":
            SuzhouGardens suzhouGardens = JSONObject.toJavaObject(jsonObject, SuzhouGardens.class);
            ret = suzhouGardensMapper.updateByPrimaryKey(suzhouGardens);
                 dcsInputCode = DcsInputCode.builder().id(suzhouGardens.getId()).updateTime(date).build();
                 dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "近现代重要史迹及代表性建筑":
            Hsataoc hsataoc = JSONObject.toJavaObject(jsonObject, Hsataoc.class);
            ret = hsataocMapper.updateByPrimaryKey(hsataoc);
                dcsInputCode = DcsInputCode.builder().id(hsataoc.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
             case "古城墙":
            OldWall oldWall = JSONObject.toJavaObject(jsonObject, OldWall.class);
            ret = oldWallMapper.updateByPrimaryKey(oldWall);
                 dcsInputCode = DcsInputCode.builder().id(oldWall.getId()).updateTime(date).build();
                 dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "传统民居":
            TraditionalHouses TraditionalHouses = JSONObject.toJavaObject(jsonObject, com.acp.model.TraditionalHouses.class);
            ret = traditionalHousesMapper.updateByPrimaryKey(TraditionalHouses);
                dcsInputCode = DcsInputCode.builder().id(TraditionalHouses.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
             case "古树名木":
            OldTree oldTree = JSONObject.toJavaObject(jsonObject, OldTree.class);
            ret = oldTreeMapper.updateByPrimaryKey(oldTree);
                 dcsInputCode = DcsInputCode.builder().id(oldTree.getId()).updateTime(date).build();
                 dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "工业遗产":
            IndustrialHeritage industrialHeritage = JSONObject.toJavaObject(jsonObject, IndustrialHeritage.class);
            ret = industrialHeritageMapper.updateByPrimaryKey(industrialHeritage);
                dcsInputCode = DcsInputCode.builder().id(industrialHeritage.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
             case "古构筑物":
            OldStructure oldStructure = JSONObject.toJavaObject(jsonObject, OldStructure.class);
            ret = oldStructureMapper.updateByPrimaryKey(oldStructure);
                 dcsInputCode = DcsInputCode.builder().id(oldStructure.getId()).updateTime(date).build();
                 dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "非物质文化遗产":
            Nch nch = JSONObject.toJavaObject(jsonObject, Nch.class);
            ret = nchMapper.updateByPrimaryKey(nch);
                dcsInputCode = DcsInputCode.builder().id(nch.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
             case "整体格局与风貌":
            LayoutStyle layoutStyle = JSONObject.toJavaObject(jsonObject, LayoutStyle.class);
            ret = layoutStyleMapper.updateByPrimaryKey(layoutStyle);
                 dcsInputCode = DcsInputCode.builder().id(layoutStyle.getId()).updateTime(date).build();
                 dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "地下文物埋藏区":
            Uar uar = JSONObject.toJavaObject(jsonObject, Uar.class);
            ret = uarMapper.updateByPrimaryKey(uar);
                dcsInputCode = DcsInputCode.builder().id(uar.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "X":
            Others others = JSONObject.toJavaObject(jsonObject, Others.class);
            ret = othersMapper.updateByPrimaryKey(others);
                dcsInputCode = DcsInputCode.builder().id(others.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
            if (ret > 0) {
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
            break;
            case "历史建筑(单体)":
                HistoricalBuildingIndividual historicalBuildingIndividual  = JSONObject.toJavaObject(jsonObject, HistoricalBuildingIndividual.class);
                ret = historicalBuildingIndividualMapper.update(historicalBuildingIndividual);
                dcsInputCode = DcsInputCode.builder().id(historicalBuildingIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            case "近现代重要史迹及代表性建筑(单体)":
                HsataocIndividual hsataocIndividual  = JSONObject.toJavaObject(jsonObject, HsataocIndividual.class);
                ret = hsataocIndividualMapper.update(hsataocIndividual);
                dcsInputCode = DcsInputCode.builder().id(hsataocIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            case "工业遗产(单体)":
                IndustrialHeritageIndividual industrialHeritageIndividual  = JSONObject.toJavaObject(jsonObject, IndustrialHeritageIndividual.class);
                ret = industrialHeritageIndividualMapper.update(industrialHeritageIndividual);
                dcsInputCode = DcsInputCode.builder().id(industrialHeritageIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            case "文控保单位(单体)":
                ProtectionUnitIndividual protectionUnitIndividual  = JSONObject.toJavaObject(jsonObject, ProtectionUnitIndividual.class);
                ret = protectionUnitIndividualMapper.update(protectionUnitIndividual);
                dcsInputCode = DcsInputCode.builder().id(protectionUnitIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            case "苏州园林(单体)":
                SuzhouGardensIndividual suzhouGardensIndividual  = JSONObject.toJavaObject(jsonObject, SuzhouGardensIndividual.class);
                ret = suzhouGardensIndividualMapper.update(suzhouGardensIndividual);
                dcsInputCode = DcsInputCode.builder().id(suzhouGardensIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            case "传统民居(单体)":
                TraditionalHousesIndividual traditionalHousesIndividual  = JSONObject.toJavaObject(jsonObject, TraditionalHousesIndividual.class);
                ret = traditionalHousesIndividualMapper.update(traditionalHousesIndividual);
                dcsInputCode = DcsInputCode.builder().id(traditionalHousesIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            case "尚未核定为文物保护单位的不可移动文物(单体)":
                UcrIndividual ucrIndividual  = JSONObject.toJavaObject(jsonObject, UcrIndividual.class);
                ret = ucrIndividualMapper.update(ucrIndividual);
                dcsInputCode = DcsInputCode.builder().id(ucrIndividual.getId()).updateTime(date).build();
                dcsInputCodeMapper.updateStatus(dcsInputCode);
                if (ret > 0) {
                    return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
                }
                break;
            default:
                break;
        }
        return ResultUtil.createWarning(Config.MESSAGE, 911, null);
    }

    /**
     * 删除
     * @param object
     * @return 返回ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public ResultInfo delObjectLst(String object) {
        try {
            String type = doValue(object, "type");
            String listValue = doValue(object, "id");
            String[] list = JSONArray.parseArray(listValue).toArray(new String[0]);
            String tableName;
            switch (type){
                case "吴文化地名":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    wuCulturePlaceMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "传统产业":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    traditionalIndustryMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "历史文化街区":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    historicalStreetMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "历史地段":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    historicalAreaMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "河道水系":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    wuCulturePlaceMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "文控保单位":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    protectionUnitMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "尚未核定为文物保护单位的不可移动文物":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    ucrMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "历史建筑":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    wuCulturePlaceMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "苏州园林":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    suzhouGardensMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "近现代重要史迹及代表性建筑":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    hsataocMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "古城墙":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    oldWallMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "传统民居":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    traditionalHousesMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "古树名木":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    oldTreeMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "工业遗产":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    industrialHeritageMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "古构筑物":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    oldStructureMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "非物质文化遗产":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    nchMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "整体格局与风貌":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    layoutStyleMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "地下文物埋藏区":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    uarMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "X":
                for (int i = 0; i < list.length; i++) {
                    retrievalMapper.deleteByPrimaryKey(list[i]);
                    othersMapper.deleteByPrimaryKey(list[i]);
                    dcsInputCodeMapper.deleteById(list[i]);
                }
                break;
                case "历史建筑(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        historicalBuildingIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                case "近现代重要史迹及代表性建筑(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        hsataocIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                case "工业遗产(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        industrialHeritageIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                case "文控保单位(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        protectionUnitIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                case "苏州园林(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        suzhouGardensIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                case "传统民居(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        traditionalHousesIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                case "尚未核定为文物保护单位的不可移动文物(单体)":
                    for (int i = 0; i < list.length; i++) {
                        retrievalMapper.deleteByPrimaryKey(list[i]);
                        ucrIndividualMapper.deleteById(list[i]);
                        dcsInputCodeMapper.deleteById(list[i]);
                    }
                    break;
                default:
                    break;
            }

            List<DcsPerformance> list1 = dcsPerformanceMapper.selectCode();
            if (list1.size() > 0) {
                for (DcsPerformance dcsPerformance : list1) {
                    String stayCount = String.valueOf(dcsPerformance.getCount());
                    String taskCode = dcsPerformance.getTask_code();
                    DcsTaskPerformance dcsTaskPerformance = DcsTaskPerformance.builder().stay_count(stayCount).task(taskCode).build();
                    List<DcsCollectCode> listNumber = dcsCollectCodeMapper.selectCountByCode(taskCode);
                    int a = listNumber.size();
                    String starsNumber = "0";
                    if (a > 0) {
                        double b = (double) (dcsPerformance.getCount() * 5) / a;
                        starsNumber = String.format("%.1f", b);
                    }
                    dcsTaskPerformance.setStars_number(starsNumber);
                    dcsTaskPerformanceMapper.updateStayCount(dcsTaskPerformance);
                }
            }
            List<DcsTaskPerformance> listAll = dcsTaskPerformanceMapper.selectAll(null);
            if (listAll.size() > 0) {
                for (DcsTaskPerformance dcsTaskPerformance : listAll) {
                    int total = Integer.valueOf(dcsTaskPerformance.getTotal_count());
                    int stay = Integer.valueOf(dcsTaskPerformance.getStay_count());
                    int complete = 0;
                    if (total >= stay) {
                        complete = total - stay;
                    }
                    String complete_count = String.valueOf(complete);
                    dcsTaskPerformance.setComplete_count(complete_count);
                    dcsTaskPerformanceMapper.updateCompleteCount(dcsTaskPerformance);
                }
            }

            return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return ResultUtil.createWarning(Config.MESSAGE, 911, null);
    }

    /**
     * 修改状态
     * @param id
     * @param tableName
     * @param status
     * @param remark
     * @param code
     * @return 返回ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    private ResultInfo reviewData(String id, String tableName, String status, String remark, String code,String inPutStatus) {
        Date date = new Date();
        long longtime = date.getTime();
        java.sql.Date time = new java.sql.Date(longtime);
        try {
            String[] list = JSONArray.parseArray(id).toArray(new String[0]);
            if ("0".equals(inPutStatus)) {
                List<String> listString = new ArrayList<>();
                for (int a = 0; a < list.length; a++) {
                    Retrieval retrieval = retrievalMapper.selectByNameAndTableName(list[a], tableName);
                    if (retrieval != null) {
                        String sql = "select count(1) from " + tableName + " where code_" + tableName + " = '" + retrieval.getCode() + "'";
                        int i = dcsSelectAllTempMapper.select(sql);
                        if (i > 0) {
                            listString.add(retrieval.getCode());
                        }
                    }
                }
                if(listString.size()>0){
                    return ResultUtil.createFail2(Config.MESSAGE, 914, listString);
                }
            }
            for (int a = 0; a < list.length; a++) {
                Retrieval retrieval = retrievalMapper.selectByNameAndTableName(list[a], tableName);
                if (retrieval != null) {
                    retrieval.setStatus(status);
                    retrieval.setRemark(remark);
                    if ("已入库".equals(status)) {
                        String sql = "select count(1) from " + tableName + " where code_" + tableName + " = '" + retrieval.getCode() + "'";
                        int i = dcsSelectAllTempMapper.select(sql);
                        if (i == 0) {
                            retrieval.setOperation("新增");
                        } else {
                            retrieval.setOperation("更新");
                        }
                        switch (tableName) {
                            case "wu_culture_place":
                                if(i == 0){
                                    WuCulturePlace wuCulturePlace = wuCulturePlaceMapper.selectByPrimaryKey(retrieval.getId());
                                    acpWuCulturePlaceMapper.insert(wuCulturePlace);
                                }else {
                                    WuCulturePlace wuCulturePlace = wuCulturePlaceMapper.selectByPrimaryKey(retrieval.getId());
                                    acpWuCulturePlaceMapper.updateByPrimaryKeySelective(wuCulturePlace);
                                }
                                break;
                            case "traditional_industry":
                                if(i == 0){
                                    TraditionalIndustry traditionalIndustry = traditionalIndustryMapper.selectByPrimaryKey(retrieval.getId());
                                    acpTraditionalIndustryMapper.insert(traditionalIndustry);
                                }else {
                                    TraditionalIndustry traditionalIndustry = traditionalIndustryMapper.selectByPrimaryKey(retrieval.getId());
                                    acpTraditionalIndustryMapper.updateByPrimaryKeySelective(traditionalIndustry);
                                }
                                break;
                            case "historical_street":
                                if(i == 0){
                                    HistoricalStreet historicalStreet = historicalStreetMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalStreetMapper.insert(historicalStreet);
                                }else {
                                    HistoricalStreet historicalStreet = historicalStreetMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalStreetMapper.updateByPrimaryKeySelective(historicalStreet);
                                }
                                break;
                            case "historical_area":
                                if(i == 0){
                                    HistoricalArea historicalArea = historicalAreaMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalAreaMapper.insert(historicalArea);
                                }else {
                                    HistoricalArea historicalArea = historicalAreaMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalAreaMapper.updateByPrimaryKey(historicalArea);
                                }
                                break;
                            case "watercourse":
                                if(i == 0){
                                    Watercourse watercourse = watercourseMapper.selectByPrimaryKey(retrieval.getId());
                                    acpWatercourseMapper.insert(watercourse);
                                }else {
                                    Watercourse watercourse = watercourseMapper.selectByPrimaryKey(retrieval.getId());
                                    acpWatercourseMapper.updateByPrimaryKeySelective(watercourse);
                                }
                                break;
                            case "protection_unit":
                                if(i == 0){
                                    ProtectionUnitWithBLOBs protectionUnit = protectionUnitMapper.selectByPrimaryKey(retrieval.getId());
                                    acpProtectionUnitMapper.insert(protectionUnit);
                                }else {
                                    ProtectionUnitWithBLOBs protectionUnit = protectionUnitMapper.selectByPrimaryKey(retrieval.getId());
                                    acpProtectionUnitMapper.updateByPrimaryKeySelective(protectionUnit);
                                }
                                break;
                            case "ucr":
                                if(i == 0){
                                    Ucr ucr = ucrMapper.selectByPrimaryKey(retrieval.getId());
                                    acpUcrMapper.insert(ucr);
                                }else {
                                    Ucr ucr = ucrMapper.selectByPrimaryKey(retrieval.getId());
                                    acpUcrMapper.updateByPrimaryKeySelective(ucr);
                                }
                                break;
                            case "historical_building":
                                if(i == 0){
                                    HistoricalBuilding historicalBuilding = historicalBuildingMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalBuildingMapper.insert(historicalBuilding);
                                }else {
                                    HistoricalBuilding historicalBuilding = historicalBuildingMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalBuildingMapper.updateByPrimaryKeySelective(historicalBuilding);
                                }
                                break;
                            case "suzhou_gardens":
                                if(i == 0){
                                    SuzhouGardens suzhouGardens = suzhouGardensMapper.selectByPrimaryKey(retrieval.getId());
                                    acpSuzhouGardensMapper.insert(suzhouGardens);
                                }else {
                                    SuzhouGardens suzhouGardens = suzhouGardensMapper.selectByPrimaryKey(retrieval.getId());
                                    acpSuzhouGardensMapper.updateByPrimaryKeySelective(suzhouGardens);
                                }
                                break;
                            case "hsataoc":
                                if(i == 0){
                                    Hsataoc hsataoc = hsataocMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHsataocMapper.insert(hsataoc);
                                }else {
                                    Hsataoc hsataoc = hsataocMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHsataocMapper.updateByPrimaryKeySelective(hsataoc);
                                }
                                break;
                            case "old_wall":
                                if(i == 0){
                                    OldWallWithBLOBs oldWall = oldWallMapper.selectByPrimaryKey(retrieval.getId());
                                    acpOldWallMapper.insert(oldWall);
                                }else {
                                    OldWallWithBLOBs oldWall = oldWallMapper.selectByPrimaryKey(retrieval.getId());
                                    acpOldWallMapper.updateByPrimaryKeySelective(oldWall);
                                }
                                break;
                            case "traditional_houses":
                                if(i == 0){
                                    TraditionalHouses traditionalHouses = traditionalHousesMapper.selectByPrimaryKey(retrieval.getId());
                                    acpTraditionalHousesMapper.insert(traditionalHouses);
                                }else {
                                    TraditionalHouses traditionalHouses = traditionalHousesMapper.selectByPrimaryKey(retrieval.getId());
                                    acpTraditionalHousesMapper.updateByPrimaryKeySelective(traditionalHouses);
                                }
                                break;
                            case "old_tree":
                                if(i == 0){
                                    OldTree oldTree = oldTreeMapper.selectByPrimaryKey(retrieval.getId());
                                    acpOldTreeMapper.insert(oldTree);
                                }else {
                                    OldTree oldTree = oldTreeMapper.selectByPrimaryKey(retrieval.getId());
                                    acpOldTreeMapper.updateByPrimaryKeySelective(oldTree);
                                }
                                break;
                            case "industrial_heritage":
                                if(i == 0){
                                    IndustrialHeritage industrialHeritage = industrialHeritageMapper.selectByPrimaryKey(retrieval.getId());
                                    acpIndustrialHeritageMapper.insert(industrialHeritage);
                                }else {
                                    IndustrialHeritage industrialHeritage = industrialHeritageMapper.selectByPrimaryKey(retrieval.getId());
                                    acpIndustrialHeritageMapper.updateByPrimaryKeySelective(industrialHeritage);
                                }
                                break;
                            case "old_structure":
                                if(i == 0){
                                    OldStructure oldStructure = oldStructureMapper.selectByPrimaryKey(retrieval.getId());
                                    acpOldStructureMapper.insert(oldStructure);
                                }else {
                                    OldStructure oldStructure = oldStructureMapper.selectByPrimaryKey(retrieval.getId());
                                    acpOldStructureMapper.updateByPrimaryKeySelective(oldStructure);
                                }
                                break;
                            case "nch":
                                if(i == 0){
                                    Nch nch = nchMapper.selectByPrimaryKey(retrieval.getId());
                                    acpNchMapper.insert(nch);
                                }else {
                                    Nch nch = nchMapper.selectByPrimaryKey(retrieval.getId());
                                    acpNchMapper.updateByPrimaryKeySelective(nch);
                                }
                                break;
                            case "uar":
                                if(i == 0){
                                    Uar uar = uarMapper.selectByPrimaryKey(retrieval.getId());
                                    acpUarMapper.insert(uar);
                                }else {
                                    Uar uar = uarMapper.selectByPrimaryKey(retrieval.getId());
                                    acpUarMapper.updateByPrimaryKeySelective(uar);
                                }
                                break;
                            case "historical_building_individual":
                                if(i == 0){
                                    HistoricalBuildingIndividual historicalBuildingIndividual = historicalBuildingIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalBuildingIndividualMapper.insert(historicalBuildingIndividual);
                                }else {
                                    HistoricalBuildingIndividual historicalBuildingIndividual = historicalBuildingIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHistoricalBuildingIndividualMapper.update(historicalBuildingIndividual);
                                }
                                break;
                            case "hsataoc_individual":
                                if(i == 0){
                                    HsataocIndividual hsataocIndividual = hsataocIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHsataocIndividualMapper.insert(hsataocIndividual);
                                }else {
                                    HsataocIndividual hsataocIndividual = hsataocIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpHsataocIndividualMapper.update(hsataocIndividual);
                                }
                                break;
                            case "industrial_heritage_individual":
                                if(i == 0){
                                    IndustrialHeritageIndividual industrialHeritageIndividual = industrialHeritageIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpIndustrialHeritageIndividualMapper.insert(industrialHeritageIndividual);
                                }else {
                                    IndustrialHeritageIndividual industrialHeritageIndividual = industrialHeritageIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpIndustrialHeritageIndividualMapper.update(industrialHeritageIndividual);
                                }
                                break;
                            case "protection_unit_individual":
                                if(i == 0){
                                    ProtectionUnitIndividual protectionUnitIndividual = protectionUnitIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpProtectionUnitIndividualMapper.insert(protectionUnitIndividual);
                                }else {
                                    ProtectionUnitIndividual protectionUnitIndividual = protectionUnitIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpProtectionUnitIndividualMapper.update(protectionUnitIndividual);
                                }
                                break;
                            case "suzhou_gardens_individual":
                                if(i == 0){
                                    SuzhouGardensIndividual suzhouGardensIndividual = suzhouGardensIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpSuzhouGardensIndividualMapper.insert(suzhouGardensIndividual);
                                }else {
                                    SuzhouGardensIndividual suzhouGardensIndividual = suzhouGardensIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpSuzhouGardensIndividualMapper.update(suzhouGardensIndividual);
                                }
                                break;
                            case "traditional_houses_individual":
                                if(i == 0){
                                    TraditionalHousesIndividual traditionalHousesIndividual = traditionalHousesIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpTraditionalHousesIndividualMapper.insert(traditionalHousesIndividual);
                                }else {
                                    TraditionalHousesIndividual traditionalHousesIndividual = traditionalHousesIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpTraditionalHousesIndividualMapper.update(traditionalHousesIndividual);
                                }
                                break;
                            case "ucr_individual":
                                if(i == 0){
                                    UcrIndividual ucrIndividual = ucrIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpUcrIndividualMapper.insert(ucrIndividual);
                                }else {
                                    UcrIndividual ucrIndividual = ucrIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                    acpUcrIndividualMapper.update(ucrIndividual);
                                }
                                break;
                            default:
                                return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
                        }
                    }
                    retrievalMapper.updateByPrimaryKeySelective(retrieval);

                    //入库修改状态
                    if (status.equals("待入库")) {
                        DcsInputCode dcsInputCode = DcsInputCode.builder().id(list[a]).status("1").aduit_time(date).build();
                        dcsInputCodeMapper.updateStatus(dcsInputCode);
                    } else if ("未通过审核".equals(status)){
                        DcsInputCode dcsInputCode = DcsInputCode.builder().id(list[a]).status("3").aduit_time(date).build();
                        dcsInputCodeMapper.updateStatus(dcsInputCode);
                    } else {
                        DcsInputCode dcsInputCode = DcsInputCode.builder().id(list[a]).status("2").in_time(date).build();
                        dcsInputCodeMapper.updateStatus(dcsInputCode);

                    }

                }
            }
            List<DcsPerformance> list1 = dcsPerformanceMapper.selectBase();
            if (list1.size() > 0) {
                for (DcsPerformance dcsPerformance : list1) {
                    String baseCount = String.valueOf(dcsPerformance.getCount());
                    String taskCode = dcsPerformance.getTask_code();
                    DcsTaskPerformance dcsTaskPerformance = DcsTaskPerformance.builder().base_count(baseCount).task(taskCode).build();
                    dcsTaskPerformanceMapper.updateBaseCount(dcsTaskPerformance);
                }
            }
            List<DcsTaskPerformance> performanceList = dcsTaskPerformanceMapper.selectAll(null);
            if (performanceList.size() > 0) {
                for (DcsTaskPerformance dcsTaskPerformance : performanceList) {
                    int StayCount = Integer.valueOf(dcsTaskPerformance.getStay_count());
                    int AdoptCount = Integer.valueOf(dcsTaskPerformance.getAdopt_count());
                    int approeRate = 0;
                    String ApproeRate = "0";
                    if (StayCount != 0) {
                        approeRate = AdoptCount * 100 / StayCount;
                        String Rate = String.valueOf(approeRate);
                        ApproeRate = Rate + "%";
                    } else {
                        approeRate = 0;
                        ApproeRate = String.valueOf(approeRate);
                    }
                    dcsTaskPerformance.setApproe_rate(ApproeRate);
                    dcsTaskPerformanceMapper.updateApproeRate(dcsTaskPerformance);
                }
            }
            return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
        } catch (Exception e) {
            Retrieval retrieval = retrievalMapper.selectByNameAndTableName(id, tableName);
            if (retrieval != null) {
                retrieval.setStatus(status);
                retrieval.setRemark(remark);
                if (status.equals("已入库")) {
                    String sql = "select count(1) from " + tableName + " where code_" + tableName + " = '" + code + "'";
                    int i = dcsSelectAllTempMapper.select(sql);
   //                 int i = 0;
                    if (i == 0) {
                        retrieval.setOperation("新增");
                    } else {
                        retrieval.setOperation("更新");
                        if ("0".equals(inPutStatus)) {
                            return ResultUtil.createFail2(Config.MESSAGE, 914, null);
                        }
                    }
                    switch (tableName) {
                        case "wu_culture_place":
                            if(i == 0){
                                WuCulturePlace wuCulturePlace = wuCulturePlaceMapper.selectByPrimaryKey(retrieval.getId());
                                acpWuCulturePlaceMapper.insert(wuCulturePlace);
                            }else {
                                WuCulturePlace wuCulturePlace = wuCulturePlaceMapper.selectByPrimaryKey(retrieval.getId());
                                acpWuCulturePlaceMapper.updateByPrimaryKeySelective(wuCulturePlace);
                            }
                            break;
                        case "traditional_industry":
                            if(i == 0){
                                TraditionalIndustry traditionalIndustry = traditionalIndustryMapper.selectByPrimaryKey(retrieval.getId());
                                acpTraditionalIndustryMapper.insert(traditionalIndustry);
                            }else {
                                TraditionalIndustry traditionalIndustry = traditionalIndustryMapper.selectByPrimaryKey(retrieval.getId());
                                acpTraditionalIndustryMapper.updateByPrimaryKeySelective(traditionalIndustry);
                            }
                            break;
                        case "historical_street":
                            if(i == 0){
                                HistoricalStreet historicalStreet = historicalStreetMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalStreetMapper.insert(historicalStreet);
                            }else {
                                HistoricalStreet historicalStreet = historicalStreetMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalStreetMapper.updateByPrimaryKeySelective(historicalStreet);
                            }
                            break;
                        case "historical_area":
                            if(i == 0){
                                HistoricalArea historicalArea = historicalAreaMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalAreaMapper.insert(historicalArea);
                            }else {
                                HistoricalArea historicalArea = historicalAreaMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalAreaMapper.updateByPrimaryKey(historicalArea);
                            }
                            break;
                        case "watercourse":
                            if(i == 0){
                                Watercourse watercourse = watercourseMapper.selectByPrimaryKey(retrieval.getId());
                                acpWatercourseMapper.insert(watercourse);
                            }else {
                                Watercourse watercourse = watercourseMapper.selectByPrimaryKey(retrieval.getId());
                                acpWatercourseMapper.updateByPrimaryKeySelective(watercourse);
                            }
                            break;
                        case "protection_unit":
                            if(i == 0){
                                ProtectionUnitWithBLOBs protectionUnit = protectionUnitMapper.selectByPrimaryKey(retrieval.getId());
                                acpProtectionUnitMapper.insert(protectionUnit);
                            }else {
                                ProtectionUnitWithBLOBs protectionUnit = protectionUnitMapper.selectByPrimaryKey(retrieval.getId());
                                acpProtectionUnitMapper.updateByPrimaryKeySelective(protectionUnit);
                            }
                            break;
                        case "ucr":
                            if(i == 0){
                                Ucr ucr = ucrMapper.selectByPrimaryKey(retrieval.getId());
                                acpUcrMapper.insert(ucr);
                            }else {
                                Ucr ucr = ucrMapper.selectByPrimaryKey(retrieval.getId());
                                acpUcrMapper.updateByPrimaryKeySelective(ucr);
                            }
                            break;
                        case "historical_building":
                            if(i == 0){
                                HistoricalBuilding historicalBuilding = historicalBuildingMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalBuildingMapper.insert(historicalBuilding);
                            }else {
                                HistoricalBuilding historicalBuilding = historicalBuildingMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalBuildingMapper.updateByPrimaryKeySelective(historicalBuilding);
                            }
                            break;
                        case "suzhou_gardens":
                            if(i == 0){
                                SuzhouGardens suzhouGardens = suzhouGardensMapper.selectByPrimaryKey(retrieval.getId());
                                acpSuzhouGardensMapper.insert(suzhouGardens);
                            }else {
                                SuzhouGardens suzhouGardens = suzhouGardensMapper.selectByPrimaryKey(retrieval.getId());
                                acpSuzhouGardensMapper.updateByPrimaryKeySelective(suzhouGardens);
                            }
                            break;
                        case "hsataoc":
                            if(i == 0){
                                Hsataoc hsataoc = hsataocMapper.selectByPrimaryKey(retrieval.getId());
                                acpHsataocMapper.insert(hsataoc);
                            }else {
                                Hsataoc hsataoc = hsataocMapper.selectByPrimaryKey(retrieval.getId());
                                acpHsataocMapper.updateByPrimaryKeySelective(hsataoc);
                            }
                            break;
                        case "old_wall":
                            if(i == 0){
                                OldWallWithBLOBs oldWall = oldWallMapper.selectByPrimaryKey(retrieval.getId());
                                acpOldWallMapper.insert(oldWall);
                            }else {
                                OldWallWithBLOBs oldWall = oldWallMapper.selectByPrimaryKey(retrieval.getId());
                                acpOldWallMapper.updateByPrimaryKeySelective(oldWall);
                            }
                            break;
                        case "traditional_houses":
                            if(i == 0){
                                TraditionalHouses traditionalHouses = traditionalHousesMapper.selectByPrimaryKey(retrieval.getId());
                                acpTraditionalHousesMapper.insert(traditionalHouses);
                            }else {
                                TraditionalHouses traditionalHouses = traditionalHousesMapper.selectByPrimaryKey(retrieval.getId());
                                acpTraditionalHousesMapper.updateByPrimaryKeySelective(traditionalHouses);
                            }
                            break;
                        case "old_tree":
                            if(i == 0){
                                OldTree oldTree = oldTreeMapper.selectByPrimaryKey(retrieval.getId());
                                acpOldTreeMapper.insert(oldTree);
                            }else {
                                OldTree oldTree = oldTreeMapper.selectByPrimaryKey(retrieval.getId());
                                acpOldTreeMapper.updateByPrimaryKeySelective(oldTree);
                            }
                            break;
                        case "industrial_heritage":
                            if(i == 0){
                                IndustrialHeritage industrialHeritage = industrialHeritageMapper.selectByPrimaryKey(retrieval.getId());
                                acpIndustrialHeritageMapper.insert(industrialHeritage);
                            }else {
                                IndustrialHeritage industrialHeritage = industrialHeritageMapper.selectByPrimaryKey(retrieval.getId());
                                acpIndustrialHeritageMapper.updateByPrimaryKeySelective(industrialHeritage);
                            }
                            break;
                        case "old_structure":
                            if(i == 0){
                                OldStructure oldStructure = oldStructureMapper.selectByPrimaryKey(retrieval.getId());
                                acpOldStructureMapper.insert(oldStructure);
                            }else {
                                OldStructure oldStructure = oldStructureMapper.selectByPrimaryKey(retrieval.getId());
                                acpOldStructureMapper.updateByPrimaryKeySelective(oldStructure);
                            }
                            break;
                        case "nch":
                            if(i == 0){
                                Nch nch = nchMapper.selectByPrimaryKey(retrieval.getId());
                                acpNchMapper.insert(nch);
                            }else {
                                Nch nch = nchMapper.selectByPrimaryKey(retrieval.getId());
                                acpNchMapper.updateByPrimaryKeySelective(nch);
                            }
                            break;
                        case "uar":
                            if(i == 0){
                                Uar uar = uarMapper.selectByPrimaryKey(retrieval.getId());
                                acpUarMapper.insert(uar);
                            }else {
                                Uar uar = uarMapper.selectByPrimaryKey(retrieval.getId());
                                acpUarMapper.updateByPrimaryKeySelective(uar);
                            }
                            break;
                        case "historical_building_individual":
                            if(i == 0){
                                HistoricalBuildingIndividual historicalBuildingIndividual = historicalBuildingIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalBuildingIndividualMapper.insert(historicalBuildingIndividual);
                            }else {
                                HistoricalBuildingIndividual historicalBuildingIndividual = historicalBuildingIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpHistoricalBuildingIndividualMapper.update(historicalBuildingIndividual);
                            }
                            break;
                        case "hsataoc_individual":
                            if(i == 0){
                                HsataocIndividual hsataocIndividual = hsataocIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpHsataocIndividualMapper.insert(hsataocIndividual);
                            }else {
                                HsataocIndividual hsataocIndividual = hsataocIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpHsataocIndividualMapper.update(hsataocIndividual);
                            }
                            break;
                        case "industrial_heritage_individual":
                            if(i == 0){
                                IndustrialHeritageIndividual industrialHeritageIndividual = industrialHeritageIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpIndustrialHeritageIndividualMapper.insert(industrialHeritageIndividual);
                            }else {
                                IndustrialHeritageIndividual industrialHeritageIndividual = industrialHeritageIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpIndustrialHeritageIndividualMapper.update(industrialHeritageIndividual);
                            }
                            break;
                        case "protection_unit_individual":
                            if(i == 0){
                                ProtectionUnitIndividual protectionUnitIndividual = protectionUnitIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpProtectionUnitIndividualMapper.insert(protectionUnitIndividual);
                            }else {
                                ProtectionUnitIndividual protectionUnitIndividual = protectionUnitIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpProtectionUnitIndividualMapper.update(protectionUnitIndividual);
                            }
                            break;
                        case "suzhou_gardens_individual":
                            if(i == 0){
                                SuzhouGardensIndividual suzhouGardensIndividual = suzhouGardensIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpSuzhouGardensIndividualMapper.insert(suzhouGardensIndividual);
                            }else {
                                SuzhouGardensIndividual suzhouGardensIndividual = suzhouGardensIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpSuzhouGardensIndividualMapper.update(suzhouGardensIndividual);
                            }
                            break;
                        case "traditional_houses_individual":
                            if(i == 0){
                                TraditionalHousesIndividual traditionalHousesIndividual = traditionalHousesIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpTraditionalHousesIndividualMapper.insert(traditionalHousesIndividual);
                            }else {
                                TraditionalHousesIndividual traditionalHousesIndividual = traditionalHousesIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpTraditionalHousesIndividualMapper.update(traditionalHousesIndividual);
                            }
                            break;
                        case "ucr_individual":
                            if(i == 0){
                                UcrIndividual ucrIndividual = ucrIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpUcrIndividualMapper.insert(ucrIndividual);
                            }else {
                                UcrIndividual ucrIndividual = ucrIndividualMapper.selectByPrimaryKey(retrieval.getId());
                                acpUcrIndividualMapper.update(ucrIndividual);
                            }
                            break;
                        default:
                            return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
                    }
                }
                retrievalMapper.updateByPrimaryKeySelective(retrieval);
                //审核通过/入库状态修改
                if (status.equals("待入库")) {
                    DcsInputCode dcsInputCode = DcsInputCode.builder().id(id).status("1").aduit_time(date).build();
                    dcsInputCodeMapper.updateStatus(dcsInputCode);
                } else if ("未通过审核".equals(status)){
                    DcsInputCode dcsInputCode = DcsInputCode.builder().id(id).status("3").aduit_time(date).build();
                    dcsInputCodeMapper.updateStatus(dcsInputCode);
                } else {
                    DcsInputCode dcsInputCode = DcsInputCode.builder().id(id).status("2").in_time(date).build();
                    dcsInputCodeMapper.updateStatus(dcsInputCode);
                }
                //审核通过量/入库量/通过率添加
                List<DcsPerformance> list = dcsPerformanceMapper.selectAdopt();
                if (list.size() > 0) {
                    for (DcsPerformance dcsPerformance : list) {
                        String adoptCount = String.valueOf(dcsPerformance.getCount());
                        String taskCode = dcsPerformance.getTask_code();
                        DcsTaskPerformance dcsTaskPerformance = DcsTaskPerformance.builder().adopt_count(adoptCount).task(taskCode).build();
                        dcsTaskPerformanceMapper.updateAdoptCount(dcsTaskPerformance);
                    }
                }
                List<DcsPerformance> list1 = dcsPerformanceMapper.selectBase();
                if (list1.size() > 0) {
                    for (DcsPerformance dcsPerformance : list1) {
                        String baseCount = String.valueOf(dcsPerformance.getCount());
                        String taskCode = dcsPerformance.getTask_code();
                        DcsTaskPerformance dcsTaskPerformance = DcsTaskPerformance.builder().base_count(baseCount).task(taskCode).build();
                        dcsTaskPerformanceMapper.updateBaseCount(dcsTaskPerformance);
                    }
                }
                List<DcsTaskPerformance> performanceList = dcsTaskPerformanceMapper.selectAll(null);
                if (performanceList.size() > 0) {
                    for (DcsTaskPerformance dcsTaskPerformance : performanceList) {
                        int StayCount = Integer.valueOf(dcsTaskPerformance.getStay_count());
                        int AdoptCount = Integer.valueOf(dcsTaskPerformance.getAdopt_count());
                        int approeRate = 0;
                        String ApproeRate = "0";
                        if (StayCount != 0) {
                            approeRate = AdoptCount * 100 / StayCount;
                            String Rate = String.valueOf(approeRate);
                            ApproeRate = Rate + "%";
                        } else {
                            approeRate = 0;
                            ApproeRate = String.valueOf(approeRate);
                        }
                        dcsTaskPerformance.setApproe_rate(ApproeRate);
                        dcsTaskPerformanceMapper.updateApproeRate(dcsTaskPerformance);
                    }
                }
                return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
            }
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
    }

    /**
     * 工具方法
     * @param object
     * @param type
     * @return 返回 String 类型字符串
     */
    private String doValue(String object, String type) {
        String value;
        try {
            Map mapObject = (Map) JSON.parse(object);
            value = mapObject.get(type).toString();
        } catch (Exception ex) {
            value = "";
        }

        return value;
    }

    /**
     * 查询
     * @param object
     * @return 返回ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public ResultInfo reviewObject(String object) {
        String type = doValue(object, "type");
        String id = doValue(object, "id");
        String status = doValue(object, "status");
        String remarks = doValue(object, "remarks");
        String code = doValue(object, "code");
        String inPutStatus = doValue(object, "inPutStatus");
        String tableName;
        ResultInfo resultInfo = null;
        switch (type) {
            case "吴文化地名":
                tableName = "wu_culture_place";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "传统产业":
                tableName = "traditional_industry";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "历史文化街区":
                tableName = "historical_street";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "历史地段":
                tableName = "historical_area";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "河道水系":
                tableName = "watercourse";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "文控保单位":
                tableName = "protection_unit";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "尚未核定为文物保护单位的不可移动文物":
                tableName = "ucr";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "历史建筑":
                tableName = "historical_building";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "苏州园林":
                tableName = "suzhou_gardens";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "近现代重要史迹及代表性建筑":
                tableName = "hsataoc";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "古城墙":
                tableName = "old_wall";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "传统民居":
                tableName = "traditional_houses";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "古树名木":
                tableName = "old_tree";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "工业遗产":
                tableName = "industrial_heritage";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "古构筑物":
                tableName = "old_structure";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "非物质文化遗产":
                tableName = "nch";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "整体格局与风貌":
                tableName = "layout_style";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "地下文物埋藏区":
                tableName = "uar";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "X":
                tableName = "others";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "历史建筑(单体)":
                tableName = "historical_building_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "近现代重要史迹及代表性建筑(单体)":
                tableName = "hsataoc_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "工业遗产(单体)":
                tableName = "industrial_heritage_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "文控保单位(单体)":
                tableName = "protection_unit_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "苏州园林(单体)":
                tableName = "suzhou_gardens_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "传统民居(单体)":
                tableName = "traditional_houses_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            case "尚未核定为文物保护单位的不可移动文物(单体)":
                tableName = "ucr_individual";
                resultInfo = reviewData(id, tableName, status, remarks, code,inPutStatus);
                break;
            default:
                resultInfo = ResultUtil.createSuccess(Config.MESSAGE, 911, null);
                break;
            }
        return resultInfo;
    }

    /**
     * 查询文件
     * @param path
     * @param code
     * @return 返回list集合
     */
    public List<String> FindFile(String path,String code){
        List<String> list = new ArrayList<>();
        File f = new File(path);
        if (!f.exists()) {
            return null;
        }
        File[] fa = f.listFiles();
        for (int i = 0; i < fa.length; i++) {
            File fs = fa[i];
            if (fs.isDirectory()) {
            } else {
                list.add(url+code+"/"+fs.getName());
            }
        }
        return list;
    }
    /**
     * 查询
     * @param type
     * @param name
     * @param status
     * @param street
     * @param level
     * @param community
     * @return list集合
     */
    private List<Object> queryList(String type, String name, String status, String street, String level, String community) {
        List<Object> list = new ArrayList<>();
        List<String> retrievalLst = new ArrayList<>();
        String tableName;
        switch (type){
            case "吴文化地名":
                tableName = "wu_culture_place";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    WuCulturePlace wuCulturePlace = wuCulturePlaceMapper.selectByPrimaryKey(id);
                    if (wuCulturePlace != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            wuCulturePlace.setStatus(model.getStatus());
                        } else {
                            wuCulturePlace.setStatus("待审核");
                        }
                        wuCulturePlace.setType("吴文化地名");
                        wuCulturePlace.setTableName(tableName);
                        String url = urlIp + wuCulturePlace.getCodeWuCulturePlace();
                        wuCulturePlace.setList(FindFile(url,wuCulturePlace.getCodeWuCulturePlace()));
                        list.add(wuCulturePlace);
                    }
                }
                break;
            case "传统产业":
                tableName = "traditional_industry";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    TraditionalIndustry traditionalIndustry = traditionalIndustryMapper.selectByPrimaryKey(id);
                    if (traditionalIndustry != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            traditionalIndustry.setStatus(model.getStatus());
                        } else {
                            traditionalIndustry.setStatus("待审核");
                        }
                        String url = urlIp + traditionalIndustry.getCodeTraditionalIndustry();
                        traditionalIndustry.setList(FindFile(url,traditionalIndustry.getCodeTraditionalIndustry()));
                        list.add(traditionalIndustry);
                    }
                }
                break;
            case "历史文化街区":
                tableName = "historical_street";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    HistoricalStreet historicalStreet = historicalStreetMapper.selectByPrimaryKey(id);
                    if (historicalStreet != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            historicalStreet.setStatus(model.getStatus());
                        } else {
                            historicalStreet.setStatus("待审核");
                        }

                        String url = urlIp + historicalStreet.getCodeHistoricalStreet();
                        historicalStreet.setList(FindFile(url,historicalStreet.getCodeHistoricalStreet()));
                        String code = historicalStreet.getCodeHistoricalStreet();
                        String sql = "select name,area,protection_grade from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        historicalStreet.setDcsCheck(dcsCheck);
                        list.add(historicalStreet);
                    }
                }
                break;
            case "历史地段":
                tableName = "historical_area";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    HistoricalArea historicalArea = historicalAreaMapper.selectByPrimaryKey(id);
                    if (historicalArea != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            historicalArea.setStatus(model.getStatus());
                        } else {
                            historicalArea.setStatus("待审核");
                        }

                        String url = urlIp + historicalArea.getCodeHistoricalArea();
                        historicalArea.setList(FindFile(url,historicalArea.getCodeHistoricalArea()));
                        String code = historicalArea.getCodeHistoricalArea();
                        String sql = "select name,address,protection_scope from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        historicalArea.setDcsCheck(dcsCheck);
                        list.add(historicalArea);
                    }
                }
                break;
            case "河道水系":
                tableName = "watercourse";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    Watercourse watercourse = watercourseMapper.selectByPrimaryKey(id);
                    if (watercourse != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            watercourse.setStatus(model.getStatus());
                        } else {
                            watercourse.setStatus("待审核");
                        }
                        String url = urlIp + watercourse.getCodeWatercourse();
                        watercourse.setList(FindFile(url,watercourse.getCodeWatercourse()));
                        String code = watercourse.getCodeWatercourse();
                        String sql = "select name,code,grade,length,mean_width,bridge from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        watercourse.setDcsCheck(dcsCheck);
                        list.add(watercourse);
                    }
                }
                break;
            case "文控保单位":
                tableName = "protection_unit";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    ProtectionUnit protectionUnit = protectionUnitMapper.selectByPrimaryKey(id);
                    if (protectionUnit != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        String dynasty = protectionUnit.getDynasty();
                        protectionUnit.setDynasty(dynasty);
                        if (model != null) {
                            protectionUnit.setStatus(model.getStatus());
                        } else {
                            protectionUnit.setStatus("待审核");
                        }
                        String url = urlIp + protectionUnit.getCodeProtectionUnit();
                        protectionUnit.setList(FindFile(url,protectionUnit.getCodeProtectionUnit()));
                        String code = protectionUnit.getCodeProtectionUnit();
                        String sql = "select name,address,category,dynasty,protection_grade from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        protectionUnit.setDcsCheck(dcsCheck);
                        list.add(protectionUnit);
                    }
                }
                break;
            case "尚未核定为文物保护单位的不可移动文物":
                tableName = "ucr";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    Ucr ucr = ucrMapper.selectByPrimaryKey(id);
                    if (ucr != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            ucr.setStatus(model.getStatus());
                        } else {
                            ucr.setStatus("待审核");
                        }
                        String dynasty = ucr.getDynasty();
                        ucr.setDynasty(dynasty);
                        String url = urlIp + ucr.getCodeUcr();
                        ucr.setList(FindFile(url,ucr.getCodeUcr()));
                        String code = ucr.getCodeUcr();
                        String sql = "select name,address,category,dynasty from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        ucr.setDcsCheck(dcsCheck);
                        list.add(ucr);
                    }
                }
                break;
            case "历史建筑":
                tableName = "historical_building";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    HistoricalBuilding historicalBuilding = historicalBuildingMapper.selectByPrimaryKey(id);
                    if (historicalBuilding != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            historicalBuilding.setStatus(model.getStatus());
                        } else {
                            historicalBuilding.setStatus("待审核");
                        }
                        String url = urlIp + historicalBuilding.getCodeHistoricalBuilding();
                        historicalBuilding.setList(FindFile(url,historicalBuilding.getCodeHistoricalBuilding()));
                        String code = historicalBuilding.getCodeHistoricalBuilding();
                        String sql = "select name,address,dynasty from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        historicalBuilding.setDcsCheck(dcsCheck);
                        list.add(historicalBuilding);
                    }
                }
                break;
            case "苏州园林":
                tableName = "suzhou_gardens";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    SuzhouGardens suzhouGardens = suzhouGardensMapper.selectByPrimaryKey(id);
                    if (suzhouGardens != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            suzhouGardens.setStatus(model.getStatus());
                        } else {
                            suzhouGardens.setStatus("待审核");
                        }
                        String dynasty = suzhouGardens.getDynasty();
                        suzhouGardens.setDynasty(dynasty);
                        String url = urlIp + suzhouGardens.getCodeSuzhouGardens();
                        suzhouGardens.setList(FindFile(url,suzhouGardens.getCodeSuzhouGardens()));
                        String code = suzhouGardens.getCodeSuzhouGardens();
                        String sql = "select name,address,dynasty,management_unit from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        suzhouGardens.setDcsCheck(dcsCheck);
                        list.add(suzhouGardens);
                    }
                }
                break;
            case "近现代重要史迹及代表性建筑":
                tableName = "hsataoc";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    Hsataoc hsataoc = hsataocMapper.selectByPrimaryKey(id);
                    if (hsataoc != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            hsataoc.setStatus(model.getStatus());
                        } else {
                            hsataoc.setStatus("待审核");
                        }
                        String url = urlIp + hsataoc.getCodeHsataoc();
                        hsataoc.setList(FindFile(url,hsataoc.getCodeHsataoc()));
                        String code = hsataoc.getCodeHsataoc();
                        String sql = "select name,address,dynasty,category,protection_grade from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        hsataoc.setDcsCheck(dcsCheck);
                        list.add(hsataoc);
                    }
                }
                break;
            case "古城墙":
                tableName = "old_wall";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    OldWall oldWall = oldWallMapper.selectByPrimaryKey(id);
                    if (oldWall != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            oldWall.setStatus(model.getStatus());
                        } else {
                            oldWall.setStatus("待审核");
                        }
                        String dynasty = oldWall.getDynasty();
                        oldWall.setDynasty(dynasty);
                        String url = urlIp + oldWall.getCodeOldWall();
                        oldWall.setList(FindFile(url,oldWall.getCodeOldWall()));
                        list.add(oldWall);
                    }
                }
                break;
            case "传统民居":
                tableName = "traditional_houses";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    TraditionalHouses TraditionalHouses = traditionalHousesMapper.selectByPrimaryKey(id);
                    if (TraditionalHouses != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            TraditionalHouses.setStatus(model.getStatus());
                        } else {
                            TraditionalHouses.setStatus("待审核");
                        }
                        String dynasty = TraditionalHouses.getDynasty();
                        TraditionalHouses.setDynasty(dynasty);
                        String url = urlIp + TraditionalHouses.getCodeTraditionalHousesGroup();
                        TraditionalHouses.setList(FindFile(url,TraditionalHouses.getCodeTraditionalHousesGroup()));
                        if ("1".equals(TraditionalHouses.getProtectionGrade())) {
                            TraditionalHouses.setGrade("优秀传统民居");
                        } else if ("2".equals(TraditionalHouses.getProtectionGrade())) {
                            TraditionalHouses.setGrade("一般传统民居");
                        }
                        list.add(TraditionalHouses);
                    }
                }
                break;
            case "古树名木":
                tableName = "old_tree";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    OldTree oldTree = oldTreeMapper.selectByPrimaryKey(id);
                    if (oldTree != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            oldTree.setStatus(model.getStatus());
                        } else {
                            oldTree.setStatus("待审核");
                        }
                        String url = urlIp + oldTree.getCodeOldTree();
                        oldTree.setList(FindFile(url,oldTree.getCodeOldTree()));
                        String code = oldTree.getCodeOldTree();
                        String sql = "select species,code,age,grade from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        oldTree.setDcsCheck(dcsCheck);
                        list.add(oldTree);
                    }
                }
                break;
            case "工业遗产":
                tableName = "industrial_heritage";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    IndustrialHeritage industrialHeritage = industrialHeritageMapper.selectByPrimaryKey(id);
                    if (industrialHeritage != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            industrialHeritage.setStatus(model.getStatus());
                        } else {
                            industrialHeritage.setStatus("待审核");
                        }
                        String url = urlIp + industrialHeritage.getCodeIndustrialHeritage();
                        industrialHeritage.setList(FindFile(url,industrialHeritage.getCodeIndustrialHeritage()));
                        String code = industrialHeritage.getCodeIndustrialHeritage();
                        String sql = "select name,address,protection_grade,start_year from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        industrialHeritage.setDcsCheck(dcsCheck);
                        list.add(industrialHeritage);
                    }
                }
                break;
            case "古构筑物":
                tableName = "old_structure";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    OldStructure oldStructure = oldStructureMapper.selectByPrimaryKey(id);
                    if (oldStructure != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            oldStructure.setStatus(model.getStatus());
                        } else {
                            oldStructure.setStatus("待审核");
                        }
                        String dynasty = oldStructure.getDynasty();
                        oldStructure.setDynasty(dynasty);
                        String url = urlIp + oldStructure.getCodeOldStructur();
                        oldStructure.setList(FindFile(url,oldStructure.getCodeOldStructur()));
                        String code = oldStructure.getCodeOldStructur();
                        String sql = "select name,address,dynasty from " + tableName + " where code_" + tableName + " = '" + code + "'";
                        DcsCheck dcsCheck = dcsCheckMapper.selectCheckData(sql);
                        oldStructure.setDcsCheck(dcsCheck);
                        list.add(oldStructure);
                    }
                }
                break;
            case "非物质文化遗产":
                tableName = "nch";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    Nch nch = nchMapper.selectByPrimaryKey(id);
                    if (nch != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            nch.setStatus(model.getStatus());
                        } else {
                            nch.setStatus("待审核");
                        }
                        String url = urlIp + nch.getCodeNch();
                        nch.setList(FindFile(url,nch.getCodeNch()));
                        list.add(nch);
                    }
                }
                break;
            case "整体格局与风貌":
                tableName = "layout_style";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    LayoutStyle layoutStyle = layoutStyleMapper.selectByPrimaryKey(id);
                    if (layoutStyle != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            layoutStyle.setStatus(model.getStatus());
                        } else {
                            layoutStyle.setStatus("待审核");
                        }
                        String url = urlIp + layoutStyle.getCodeLayoutStyle();
                        layoutStyle.setList(FindFile(url,layoutStyle.getCodeLayoutStyle()));
                        list.add(layoutStyle);
                    }
                }
                break;
            case "地下文物埋藏区":
                tableName = "uar";
                retrievalLst = retrievalMapper.selectByUar(name, status, tableName);
                for (String id : retrievalLst) {
                    Uar uar = uarMapper.selectByPrimaryKey(id);
                    if (uar != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            uar.setStatus(model.getStatus());
                        } else {
                            uar.setStatus("待审核");
                        }
                        String url = urlIp + uar.getCodeUar();
                        uar.setList(FindFile(url,uar.getCodeUar()));
                        list.add(uar);
                    }
                }
                break;
            case "X":
                tableName = "others";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    Others others = othersMapper.selectByPrimaryKey(id);
                    if (others != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            others.setStatus(model.getStatus());
                        } else {
                            others.setStatus("待审核");
                        }
                        String url = urlIp + others.getCodeOthers();
                        others.setList(FindFile(url,others.getCodeOthers()));
                        list.add(others);
                    }
                }
                break;
            case "历史建筑(单体)":
                tableName = "historical_building_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    HistoricalBuildingIndividual historicalBuildingIndividual = historicalBuildingIndividualMapper.selectByPrimaryKey(id);
                    if (historicalBuildingIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            historicalBuildingIndividual.setStatus(model.getStatus());
                        } else {
                            historicalBuildingIndividual.setStatus("待审核");
                        }
                        String url = urlIp + historicalBuildingIndividual.getCodeHistoricalBuildingIndividual();
                        historicalBuildingIndividual.setList(FindFile(url, historicalBuildingIndividual.getCodeHistoricalBuildingIndividual()));
                        list.add(historicalBuildingIndividual);
                    }
                }
                break;
            case "近现代重要史迹及代表性建筑(单体)":
                tableName = "hsataoc_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    HsataocIndividual hsataocIndividual = hsataocIndividualMapper.selectByPrimaryKey(id);
                    if (hsataocIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            hsataocIndividual.setStatus(model.getStatus());
                        } else {
                            hsataocIndividual.setStatus("待审核");
                        }
                        String url = urlIp + hsataocIndividual.getCodeHsataocIndividual();
                        hsataocIndividual.setList(FindFile(url,hsataocIndividual.getCodeHsataocIndividual()));
                        list.add(hsataocIndividual);
                    }
                }
                break;
            case "工业遗产(单体)":
                tableName = "industrial_heritage_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    IndustrialHeritageIndividual industrialHeritageIndividual = industrialHeritageIndividualMapper.selectByPrimaryKey(id);
                    if (industrialHeritageIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            industrialHeritageIndividual.setStatus(model.getStatus());
                        } else {
                            industrialHeritageIndividual.setStatus("待审核");
                        }
                        String url = urlIp + industrialHeritageIndividual.getCodeIndustrialHeritageIndividual();
                        industrialHeritageIndividual.setList(FindFile(url, industrialHeritageIndividual.getCodeIndustrialHeritageIndividual()));
                        list.add(industrialHeritageIndividual);
                    }
                }
                break;
            case "文控保单位(单体)":
                tableName = "protection_unit_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    ProtectionUnitIndividual protectionUnitIndividual = protectionUnitIndividualMapper.selectByPrimaryKey(id);
                    if (protectionUnitIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            protectionUnitIndividual.setStatus(model.getStatus());
                        } else {
                            protectionUnitIndividual.setStatus("待审核");
                        }
                        String url = urlIp + protectionUnitIndividual.getCodeProtectionUnitIndividual();
                        protectionUnitIndividual.setList(FindFile(url,protectionUnitIndividual.getCodeProtectionUnitIndividual()));
                        list.add(protectionUnitIndividual);
                    }
                }
                break;
            case "苏州园林(单体)":
                tableName = "suzhou_gardens_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    SuzhouGardensIndividual suzhouGardensIndividual = suzhouGardensIndividualMapper.selectByPrimaryKey(id);
                    if (suzhouGardensIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            suzhouGardensIndividual.setStatus(model.getStatus());
                        } else {
                            suzhouGardensIndividual.setStatus("待审核");
                        }
                        String url = urlIp + suzhouGardensIndividual.getCodeSuzhouGardensIndividual();
                        suzhouGardensIndividual.setList(FindFile(url, suzhouGardensIndividual.getCodeSuzhouGardensIndividual()));
                        list.add(suzhouGardensIndividual);
                    }
                }
                break;
            case "传统民居(单体)":
                tableName = "traditional_houses_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    TraditionalHousesIndividual traditionalHousesIndividual = traditionalHousesIndividualMapper.selectByPrimaryKey(id);
                    if (traditionalHousesIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            traditionalHousesIndividual.setStatus(model.getStatus());
                        } else {
                            traditionalHousesIndividual.setStatus("待审核");
                        }
                        String url = urlIp + traditionalHousesIndividual.getCodeTraditionalHousesIndividual();
                        traditionalHousesIndividual.setList(FindFile(url, traditionalHousesIndividual.getCodeTraditionalHousesIndividual()));
                        list.add(traditionalHousesIndividual);
                    }
                }
                break;
            case "尚未核定为文物保护单位的不可移动文物(单体)":
                tableName = "ucr_individual";
                retrievalLst = retrievalMapper.selectByAny(new Retrieval(name, status, tableName, level, community, street));
                for (String id : retrievalLst) {
                    UcrIndividual ucrIndividual = ucrIndividualMapper.selectByPrimaryKey(id);
                    if (ucrIndividual != null) {
                        Retrieval model = retrievalMapper.selectByPrimaryKey(id);
                        if (model != null) {
                            ucrIndividual.setStatus(model.getStatus());
                        } else {
                            ucrIndividual.setStatus("待审核");
                        }
                        String url = urlIp + ucrIndividual.getCodeUcrIndividual();
                        ucrIndividual.setList(FindFile(url, ucrIndividual.getCodeUcrIndividual()));
                        list.add(ucrIndividual);
                    }
                }
                break;
            default:
                break;
        }
        return list;
    }

    /**
     * 查询所有
     * @param object
     * @return 返回PageResult 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public PageResult findAllList(String object) {
        String searchMap = doValue(object, "searchMap");
        String type = doValue(object, "type");
        String name = doValue(searchMap, "name");
        String status = doValue(searchMap, "status");
        String street = doValue(searchMap, "street");
        String level = doValue(searchMap, "level");
        String community = doValue(searchMap, "community");
        List<Object> list;
        list = queryList(type, name, status, street, level, community);

        return PageResult.success(list, (long) list.size());
    }

    /**
     * 通过街道查询
     * @param object
     * @return 返回PageResult 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public PageResult queryByStreet(String object) {
        List<String> lst = streetCommunityMapper.queryAcpListByStreetName(object);
        return PageResult.success(lst, (long) lst.size());
    }

    /**
     * 查询excel中数据类型
     * @param file
     * @param type
     * @return 返回ResultInfo 封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public ResultInfo resolveExcel(MultipartFile file, String type) {
        String tableName = "";
        switch (type){
            case "吴文化地名":
            tableName = "wu_culture_place";
            break;
            case "传统产业":
            tableName = "traditional_industry";
            break;
            case "历史文化街区":
            tableName = "historical_street";
            break;
            case "历史地段":
            tableName = "historical_area";
            break;
            case "河道水系":
            tableName = "watercourse";
            break;
            case "文控保单位":
            tableName = "protection_unit";
            break;
            case "尚未核定为文物保护单位的不可移动文物":
            tableName = "ucr";
            break;
            case "历史建筑":
            tableName = "historical_building";
            break;
            case "苏州园林":
            tableName = "suzhou_gardens";
            break;
            case "近现代重要史迹及代表性建筑":
            tableName = "hsataoc";
            break;
            case "古城墙":
            tableName = "old_wall";
            break;
            case "传统民居":
            tableName = "traditional_houses";
            break;
            case "古树名木":
            tableName = "old_tree";
            break;
            case "工业遗产":
            tableName = "industrial_heritage";
            break;
            case "古构筑物":
            tableName = "old_structure";
            break;
            case "非物质文化遗产":
            tableName = "nch";
            break;
            case "整体格局与风貌":
            tableName = "layout_style";
            break;
            case "地下文物埋藏区":
            tableName = "uar";
            break;
            case "X":
            tableName = "others";
            break;
            default:
                break;
        }

        List<String> keys = dictMapper.selectColumnKeyResult(tableName);
        List<String> values = dictMapper.selectColumnValueResult(tableName);
        values.add("X");
        values.add("Y");
        values.add("geometry");
        values.add("extra");
        if (file != null) {
            //获取文件的名字
            String originalFilename = file.getOriginalFilename();
            Workbook workbook = null;
            try {
                if (originalFilename.endsWith(".xls")) {
                    workbook = new HSSFWorkbook(file.getInputStream());
                } else if (originalFilename.endsWith(".xlsx")) {
                    workbook = new XSSFWorkbook(file.getInputStream());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (workbook != null) {
                //获取一个sheet也就是一个工作簿
                Sheet sheet = workbook.getSheetAt(0);
                int lastRowNum = sheet.getLastRowNum();
                List<Integer> indexLst = new ArrayList<>();
                List<String> newKeys = new ArrayList<>();
                int nameIndex = 99;
                int codeIndex = 99;
                int uarIndex = 0;
                int index = 99;
                int xIndex = 99;
                int yIndex = 99;
                int geometryIndex = 99;
                int extraIndex = 99;
                if (lastRowNum >= 1) {
                    Row row0 = sheet.getRow(0);
                    int coloumNum = sheet.getRow(0).getPhysicalNumberOfCells();
                    for (int i = 0; i < coloumNum; i++) {
                        if (values.contains(String.valueOf(row0.getCell(i)).replace("\"", ""))) {
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("名称") > -1 || String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("城门名称") > -1) {
                                nameIndex = i;
                            }
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("树木编号") > -1) {
                                codeIndex = i;
                            }
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("院落编号") > -1) {
                                index = i;
                            }
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("X") > -1) {
                                xIndex = i;
                            }
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("Y") > -1) {
                                yIndex = i;
                            }
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("geometry") > -1) {
                                geometryIndex = i;
                            }
                            if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("extra") > -1) {
                                extraIndex = i;
                            }
                            if ("uar".equals(tableName)) {
                                if (String.valueOf(row0.getCell(i)).replace("\"", "").indexOf("编号") > -1) {
                                    uarIndex = i;
                                }
                            }
                            if (xIndex == 99 && yIndex == 99) {
                                indexLst.add(i);
                                newKeys.add(keys.get(values.indexOf(String.valueOf(row0.getCell(i)).replace("\"", ""))));
                            }
                        }
                    }
                    String column = "id" + ", " + newKeys.toString().replace("[", "").replace("]", "");
                    for (int j = 1; j <= lastRowNum; j++) {
                        String value = "";
                        Row row = sheet.getRow(j);
                        String id = UUIDBuild.getUUID();
                        if (row.getCell(indexLst.get(1)).toString().length() > 0) {
                            if (indexLst.size() > 2) {
                                Object code = row.getCell(indexLst.get(1));
                                Date date = new Date();
                                long longtime = date.getTime();
                                java.sql.Date inputTime = new java.sql.Date(longtime);
                                DcsInputCode dcsInputCode = DcsInputCode.builder().id(id).code(code.toString()).status("0").input_time(inputTime).build();
                                dcsInputCodeMapper.insert(dcsInputCode);
                            }
                            for (int z = 0; z < indexLst.size(); z++) {
                                Object modelValue = row.getCell(indexLst.get(z));
                                if (modelValue == null) {
                                    modelValue = "";
                                }
                                if (value.equals("")) {
                                    value += "'" + modelValue + "'";
                                } else {
                                    value += ",'" + modelValue + "'";
                                }
                            }
                            String name = "";
                            String sql = "";
                            String sql1 = "";
                            if ("古树名木".equals(type)) {
                                name = row.getCell(codeIndex).toString();
                            } else if ("传统民居".equals(type)) {
                                name = row.getCell(index).toString();
                            } else if ("地下文物埋藏区".equals(type)) {
                                name = row.getCell(uarIndex).toString();
                            } else {
                                name = row.getCell(nameIndex).toString();
                            }
                            Retrieval retrieval = retrievalMapper.selectByName(new Retrieval(name, tableName));
                            if (retrieval == null) {
                                Date date = new Date();
                                long longtime = date.getTime();
                                java.sql.Date time = new java.sql.Date(longtime);
                                String geometry = null;
                                String extra = null;
                                if (row.getCell(geometryIndex) != null) {
                                    geometry = row.getCell(geometryIndex).toString();
                                }
                                if (row.getCell(extraIndex) != null) {
                                    extra = row.getCell(extraIndex).toString();
                                }
                                sql1 = "insert into object_manager(id,name,table_name,time ,status) values ('" + id + "','" + name + "','" + tableName + "','" + time + "','待审核')";
                                if ("historical_street".equals(tableName) || "historical_area".equals(tableName) || "wu_culture_place".equals(tableName) || "traditional_industry".equals(tableName) || "nch".equals(tableName)) {
                                    sql = "insert into " + tableName + "(" + column + ",point) values ('" + id + "'," + value + ",st_geomfromtext('point(" + row.getCell(xIndex).toString() + " " + row.getCell(yIndex).toString() + ")'))";
                                } else if ("layout_style".equals(tableName) || "others".equals(tableName)) {
                                    sql = "insert into " + tableName + "(" + column + ") values ('" + id + "'," + value + ")";
                                } else if ("old_wall".equals(tableName)) {
                                    sql = "insert into " + tableName + "(" + column + ",point,geometry,extra_geometry) values ('" + id + "'," + value + ",st_geomfromtext('point(" + row.getCell(xIndex).toString() + " " + row.getCell(yIndex).toString() + ")'),ST_GeomFromText('" + geometry + "'),null)";
                                } else {
                                    sql = "insert into " + tableName + "(" + column + ",point) values ('" + id + "'," + value + ",st_geomfromtext('point(" + row.getCell(xIndex).toString() + " " + row.getCell(yIndex).toString() + ")'))";
                                }
                                dictMapper.insertObjectBatch(sql);
                                retrievalMapper.insertObjectBatch(sql1);
                            }
                        }
                    }
                }
            }
        }
        List<DcsPerformance> list = dcsPerformanceMapper.selectCode();
        if (list.size() > 0) {
            for (DcsPerformance dcsPerformance : list) {
                String stayCount = String.valueOf(dcsPerformance.getCount());
                String taskCode = dcsPerformance.getTask_code();
                DcsTaskPerformance dcsTaskPerformance = DcsTaskPerformance.builder().stay_count(stayCount).task(taskCode).build();
                List<DcsCollectCode> listNumber = dcsCollectCodeMapper.selectCountByCode(taskCode);
                int a = listNumber.size();
                String starsNumber = "0";
                if (a > 0) {
                    double b = (double) (dcsPerformance.getCount() * 5) / a;
                    starsNumber = String.valueOf(b);
                }
                dcsTaskPerformance.setStars_number(starsNumber);
                dcsTaskPerformanceMapper.updateStayCount(dcsTaskPerformance);
            }
        }
        List<DcsTaskPerformance> listAll = dcsTaskPerformanceMapper.selectAll(null);
        if (listAll.size() > 0) {
            for (DcsTaskPerformance dcsTaskPerformance : listAll) {
                int total = Integer.valueOf(dcsTaskPerformance.getTotal_count());
                int stay = Integer.valueOf(dcsTaskPerformance.getStay_count());
                int complete = 0;
                if (total >= stay) {
                    complete = total - stay;
                }
                String complete_count = String.valueOf(complete);
                dcsTaskPerformance.setComplete_count(complete_count);
                dcsTaskPerformanceMapper.updateCompleteCount(dcsTaskPerformance);
            }
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
    }

    /**
     * 查询字典表
     * @return 返回PageResult封装的返回参数  保存成功msg:906 保存失败msg:911
     */
    @Override
    public PageResult queryDict() {
        PageResult pageResult = new PageResult();
        Map<String, Object> dictMap = new HashMap<>();
        List<String> dictLst = dictMapper.selectByDistinct();
        for (int i = 0; i < dictLst.size(); i++) {
            List<Dict> list = dictMapper.selectByType(dictLst.get(i));
            dictMap.put(dictLst.get(i), list);
        }
        pageResult.setMapData(dictMap);
        pageResult.setMessageCode(200);
        pageResult.setMessage("加载成功");
        return pageResult;
    }

    @Override
    public List<DcsTypeNum> selectCountByType() {
        List<DcsTypeNum> list = new ArrayList<>();
        DcsTypeNum dcsTypeNum = DcsTypeNum.builder().build();
        dcsTypeNum = DcsTypeNum.builder().tableName("historical_street").tableNameChinese("历史文化街区").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("traditional_industry").tableNameChinese("传统产业").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("old_wall").tableNameChinese("古城墙").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("historical_area").tableNameChinese("历史地段").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("industrial_heritage").tableNameChinese("工业遗产").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("old_tree").auditCount(0).tableNameChinese("古树名木").adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("watercourse").tableNameChinese("河道水系").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("historical_building").tableNameChinese("历史建筑").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("nch").tableNameChinese("非物质文化遗产").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("old_structure").tableNameChinese("古构筑物").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("uar").auditCount(0).tableNameChinese("地下文物埋藏区").adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("traditional_houses").tableNameChinese("传统民居").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("protection_unit").tableNameChinese("文控保单位").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("suzhou_gardens").tableNameChinese("苏州园林").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("ucr").tableNameChinese("尚未核定为文物保护单位的不可移动文物").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("wu_culture_place").tableNameChinese("吴文化地名").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("hsataoc").tableNameChinese("近现代重要史迹及代表性建筑").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("others").tableNameChinese("其他").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);

        // 单体
        dcsTypeNum = DcsTypeNum.builder().tableName("historical_building_individual").tableNameChinese("历史建筑(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("industrial_heritage_individual").tableNameChinese("工业遗产(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("protection_unit_individual").tableNameChinese("文控保单位(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("suzhou_gardens_individual").tableNameChinese("苏州园林(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("traditional_houses_individual").tableNameChinese("传统民居(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("hsataoc_individual").tableNameChinese("近现代重要史迹及代表性建筑(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);
        dcsTypeNum = DcsTypeNum.builder().tableName("ucr_individual").tableNameChinese("尚未核定为文物保护单位的不可移动文物(单体)").auditCount(0).adoptCount(0).rejectCount(0).putCount(0).build();
        list.add(dcsTypeNum);

        List<Retrieval> listAudit = selectNumByStatus("待审核");
        if (listAudit.size()>0) {
            for (Retrieval retrieval : listAudit) {
                String tableName = retrieval.getTableName();
                for (DcsTypeNum dcsTypeNum1 : list) {
                    if (dcsTypeNum1.getTableName().equals(tableName)) {
                        dcsTypeNum1.setAuditCount(retrieval.getCount());
                    }
                }
            }
        }

        List<Retrieval> listAdopt = selectNumByStatus("待入库");
        if (listAdopt.size()>0) {
            for (Retrieval retrieval : listAdopt) {
                String tableName = retrieval.getTableName();
                for (DcsTypeNum dcsTypeNum1 : list) {
                    if (dcsTypeNum1.getTableName().equals(tableName)) {
                        dcsTypeNum1.setAdoptCount(retrieval.getCount());
                    }
                }
            }
        }

        List<Retrieval> listReject = selectNumByStatus("未通过审核");
        if (listReject.size()>0) {
            for (Retrieval retrieval : listReject) {
                String tableName = retrieval.getTableName();
                for (DcsTypeNum dcsTypeNum1 : list) {
                    if (dcsTypeNum1.getTableName().equals(tableName)) {
                        dcsTypeNum1.setRejectCount(retrieval.getCount());
                    }
                }
            }
        }

        List<Retrieval> listPut = selectNumByStatus("已入库");
        if (listPut.size()>0) {
            for (Retrieval retrieval : listPut) {
                String tableName = retrieval.getTableName();
                for (DcsTypeNum dcsTypeNum1 : list) {
                    if (dcsTypeNum1.getTableName().equals(tableName)) {
                        dcsTypeNum1.setPutCount(retrieval.getCount());
                    }
                }
            }
        }
        return list;
    }

    /**
     * 工具类方法
     * @param status
     * @return
     */
    private List<Retrieval> selectNumByStatus(String status){
        List<Retrieval> list = retrievalMapper.selectCountByType(status);
        return list;
    }
}
